// pages/test/test.js
var template = require('../../template/template.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    sections: [{
        "name": "综合",
        "active": true,
        "section_id": 0
      },
      {
        "name": "外语",
        "active": false,
        "section_id": 1
      },
      {
        "name": "政治",
        "active": false,
        "section_id": 2
      },
    ],
    array: ['1996', '1997', '1998', '1999', '2000', '2001', '2002', '2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010', '2011', '2012', '2013', '2014', '2015', '2016', '2017'],
    index: 21,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    template.tabbar("tabBar", 2, this) //0表示第一个tabbar
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  },
  onSectionClicked: function (e) {
    var sid = e.currentTarget.dataset.sid;
    var that = this
    //刷新选中状态
    if (sid === 0){
      that.data.sections[0]['active'] = true
      that.data.sections[1]['active'] = false
      that.data.sections[2]['active'] = false
    } else if (sid === 1){
      that.data.sections[0]['active'] = false
      that.data.sections[1]['active'] = true
      that.data.sections[2]['active'] = false
    }else{
      that.data.sections[0]['active'] = false
      that.data.sections[1]['active'] = false
      that.data.sections[2]['active'] = true
    }
    this.setData({
      sections: that.data.sections
    });
  },
  bindPickerChange: function (e) {
    var that = this
    var index_now = e.detail.value
    this.setData({
      index: index_now
    });
  },
  ActionTest: function (e){
    wx.redirectTo({
      url: '../brush/brush',
    })
  }
})